<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS自定义对象</title>
</head>
<body>
<script>
    // JS自定义对象
    let person = {
        name: "顶得住",
        age: 18,
        eat: function () {
            document.write("我顶不住了" + "<br/>");
        },
        sleep: function (hour) {
            document.write("睡了" + hour + "小时" + "<br/>");
        }
    };

    document.write(person.name + "<br/>");
    document.write(person.age + "<br/>");
    person.eat();
    person.sleep(8);
</script>
</body>
</html>